#coding=utf-8
import requests
from bs4 import BeautifulSoup
import lxml

resp=requests.get('https://www.baidu.com')
print(resp)
print(resp.content)

bsobj=BeautifulSoup(resp.content,'lxml') #将网页源码构造成BeautifulSoup对象，方便操作
a_list = bsobj.find_all('a')  #获取网页中的所有a标签对象
text = ''
for a in a_list:
    href =a.get('href')
    text += href+'\n'
with open('url.txt','w') as f:
    f.write(text)

